Today we will…
A structured way for tracking changes to files over the course of a project.
Makes it easy to have multiple people working on the same files at the same time.
You can host a URL of fun things (like the class text, these slides, a personal website, etc.) with GitHub pages.
Think “track-changes” or “drop-box” history, but more structured.
You may have code, documentation, data, TODO lists, and more associated with a project.
To create a repository, you can start with your local computer first, or you can start with the remote (online) repository first.
Clone = create an exact copy locally
Git tracks changes to each file that it is told to monitor, and as the files change, you provide short labels describing what the changes were and why they exist (called “commits”).
The log of these changes (along with the file history) is called your git commit history. This means you can always go back to old copies!
Updates the copy of the repository on another machine (e.g. on GitHub) so that it has the most recent changes you’ve made to your machine.
Updates your local copy of the repository (the copy on your computer) with the files that are “in the cloud” (on GitHub).
Occur when you make changes to the same line as a collaborator either at the same time, or without starting from the same “state”.
Starting a new project/local repo
Starting a new project/local repo
Working with an existing local repo
Work in your terminal or an .Rscript for this…
Generate tokenWarning
GitHub really doesn’t like it when you do not have a PAT expiration date… but I don’t ever want to deal with it again. Make sure your expiration date is AT LEAST through the end of the quarter (60 days).
Enter password or token: Paste PATYou should be good to go! Let’s verify.
Collaborating within a GitHub Repo
Designate each person to one of the suits – you will be referencing it as you work through this activity.
Warning
If you only have 3 group members here, assign one person both and
.
Please use sticky notes to indicate how your group is doing:
Blue
– We are ready to move onYellow
– We’re figuring it outRed
– Please help!!Repositories > New
stat-331-PA6.gitignore template: RSettings tab > Click on Collaborators > Add people
View invite > Accept invitegithub.com/
File > New Project > Version Control > Git (pause)<> Code and paste into Repository URL in RStudioBrowse and navigate to where you want to create your new project. I recommend creating this on your desktop.Danger
Do not save this within your master stat 331 folder!!! We don’t want to embed and Rproject within an RProject.
Create ProjectPA6.qmd in your stat-331-PA6 desktop folderself-contained: true to the YAML.gitignore file to include *.RprojGit pane > Commit > Stage (or checkmark) files > Commit message > Commit
.gitignore file with an explanatory message such as “Ignoring all .Rproj files in repo”PA6.qmd, and PA6.html files with an explanatory message such as “Created practice activity quarto file”Push the changes to the remote repository
Git pane > Pull the changes that were made!Everyone should now have the .qmd and .html files in their local repos!
author: to the YAML and include everyone’s first namesGit pane > Commit > Stage (or checkmark) files > Commit message > Commit
Push the changes
Do not pull the changes that were made!
author: to the YAML and to include everyone’s first and last names.Git pane > Commit > Stage (or checkmark) files > Commit message > Commit
Push your changesDanger
Oh no 😱 You got an error! Ugh. We forgot to pull before we started making changes 😢
Pull the changes from the repoTip
Note how the conflicting lines are marked! You might need to submit this to Canvas 😄
Commit your changesPush the changes to the repository
Do not pull the changes that were made!
Commit your changesPush your changesWarning
You will get an error, read it, and pull.
No merge conflicts should occur. Now push your changes.
Do not pull the changes that were made!
Commit your changesPush the changes to the repositoryDanger
You will get an error. Ugh!!!! We forgot to pull again!
Pull the changes from the repoCommit your changesPush you changes
Pull, and observe the changes in your document.
Note
How does Git mark the start of lines with a merge conflict? Specifically, I want the four capital letter characters with which every conflict is marked.
Always pull before you start working and always push after you are done working!
In general, if you follow the workflow for an existing local repo exactly, you only have problems if two of you are making local changes to the same line in the same file at the same time.
If you are working with collaborators in real time, pull, commit, and push often.
Git commits lines – lines of code, lines of text, etc.
Burn your local repo to the ground and clone again.
Note
No individual office hours Friday this week.
Office hours extended Tuesday from 10am - 12pm.
NO CLASS MONDAY, 2/20
Read Chapter 7: Writing Functions
Final Project Group Contract
Bonus Challenge - Data Mishaps Night